package com.zk.yygh.task.scheduled;

import com.zk.yygh.rabbit.constant.MqConst;
import com.zk.yygh.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: 张凯
 * @date: 2022/6/25 - 9:47
 */
@Component
@EnableScheduling   //开启定时任务
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    //声明一个定时任务：cron只支持六位
    //每天早上八点进行通知
    @Scheduled(cron = "0 0 8 * * ?")
    public void task1(){
        //给定时任务交换机及定时任务的路由发送消息
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"");
    }
}
